package com.jarvis.pzz.modules.shop.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.jarvis.pzz.R;
import com.jarvis.pzz.models.SearchTypeModel;
import com.jarvis.pzz.util.ViewHolderUtil;

import java.util.List;

/**
 * Created by jarvis.liu on 9/12/2016.
 */
public class ScreenAdapter extends BaseAdapter {
    private List<SearchTypeModel> list;
    private Context context;

    public ScreenAdapter(List<SearchTypeModel> list, Context context) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        SearchTypeModel searchTypeModel = list.get(position);
        convertView = LayoutInflater.from(context).inflate(R.layout.item_screen, null);
        TextView tv_name = ViewHolderUtil.get(convertView, R.id.tv_name);
        tv_name.setText(searchTypeModel.getDisplayValue());
        if (searchTypeModel.isSelect()) {
            tv_name.setTextColor(context.getResources().getColor(R.color.purple));
        } else {
            tv_name.setTextColor(context.getResources().getColor(R.color.grey_5));
        }
        return convertView;
    }
}
